package com.learn.training.multithread.chapter6.minchapter7.demo2;

import java.util.ArrayList;
import java.util.Arrays;

public class Demo {
    public static void main(String[] args) {
        Point point = new Point();
        ArrayList<Thread> ts = new ArrayList<Thread>();
        for (int i = 0; i < 20; i++) {
            Thread t = new Thread(() -> {
                double[] result = point.getXY();
                System.out.println(Thread.currentThread().getName() + "    :    x : " + result[0] + "   y:  " + result[1]);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
            t.start();
        }

        for (int i = 0; i < 5; i++) {
            Thread t1 = new Thread(() -> {
                point.moveIfAtOrigin(1, 1);
            });
            t1.start();
        }




    }
}
